// 定义XsysDictionaryGrid类的构造函数
var XsysDictionaryGrid = function (cfg) {

    // 为了在任何情况下可以获得XsysDictionaryGrid的实例对象
    var me = this;

    // 调用父类构造函数
    XsysDictionaryGrid.superclass.constructor.call(this, Ext.apply({
        url: 'xsys/dictionary/list',
        woIdProperty: 'id',
        woNameProperty: 'dicType',
        woTitle: '数据字典列表',
        singleSelect: false,
        woPaging : true,
        woColumns: [
                        {
            header: 'ID',
            dataIndex: 'id',
            hidden: true,
            width: 150
        }
                        ,{
            header: '类型',
            dataIndex: 'dicType',
            hidden: false,
            width: 150
        }
                ,{
            header: '值',
            dataIndex: 'val',
            hidden: false,
            width: 150
        }
                ,{
            header: '键',
            dataIndex: 'name',
            hidden: false,
            width: 150
        }
                ,{
            header: '描述',
            dataIndex: 'description',
            hidden: false,
            width: 150
        }
                ,{
            header: '参数',
            dataIndex: 'params',
            hidden: false,
            width: 150
        }
                                ],
        woButtons: [{
            woButtonType: 'wo.list.create', // 创建按钮
            woForm: XsysDictionaryCreateForm, // 创建表单类
            woGridSelectType: 'singleornone' // 设置列表选择类型：单选或者不选
        }, {
            woButtonType: 'wo.list.delete', // 删除按钮
            woGridSelectType: 'single', // 设置列表选择类型：单选
            woUrl: 'xsys/dictionary/delete' // 设置删除提交url，key值为selectedIds
        }],
        // 查询字段
        woSearchFields: [{
            items: [{
                name: 'searchContent',
                fieldLabel: '查询内容',
                width: 100
            }]
        }],
        woUpdateForm: XsysDictionaryUpdateForm // 设置列表双击时，弹出的修改表单类
    }, cfg));
};
// XsysDictionaryGrid继承Wo.GridPanel
Ext.extend(XsysDictionaryGrid, Wo.GridPanel, {});


// 定义数据字典的创建表单，继承Wo.FormPanel
var XsysDictionaryCreateForm = function (cfg) {
    // 调用父类构造函数
    XsysDictionaryCreateForm.superclass.constructor.call(this, Ext.apply({
        columns: 1,
        url: 'xsys/dictionary/create',
        title: '创建数据字典',
        width: 400,
        height: 300,
        items: [
    	                {
            items: [{
                name: 'id',
                fieldLabel: 'ID',
                                allowBlank: true,
                width: 200
            }]
        }
                        , {
            items: [{
                name: 'dicType',
                fieldLabel: '类型',
                allowBlank: true,
                                width: 200
            }]
        }
                , {
            items: [{
                name: 'val',
                fieldLabel: '值',
                allowBlank: true,
                                width: 200
            }]
        }
                , {
            items: [{
                name: 'name',
                fieldLabel: '键',
                allowBlank: true,
                                width: 200
            }]
        }
                , {
            items: [{
                name: 'description',
                fieldLabel: '描述',
                allowBlank: true,
                                width: 200
            }]
        }
                , {
            items: [{
                name: 'params',
                fieldLabel: '参数',
                allowBlank: true,
                                width: 200
            }]
        }
                                ]
    }, cfg));
};
// 继承
Ext.extend(XsysDictionaryCreateForm, Wo.FormPanel, {});

// 定义数据字典修改表单
var XsysDictionaryUpdateForm = function (cfg) {
    XsysDictionaryUpdateForm.superclass.constructor.call(this, Ext.apply({
        columns: 1,
        url: 'xsys/dictionary/update',
        title: '修改数据字典',
        width: 400,
        height: 300,
        items: [
    	                {
            items: [{
                name: 'id',
                fieldLabel: 'ID',
                width: 200,
                readOnly: true,
                value: cfg.row.get('id')
            }]
        }
    	    	        , {
            items: [{
                name: 'dicType',
                fieldLabel: '类型',
                width: 200,
                                allowBlank: true,
                value: cfg.row.get('dicType')
            }]
        }
    	        , {
            items: [{
                name: 'val',
                fieldLabel: '值',
                width: 200,
                                allowBlank: true,
                value: cfg.row.get('val')
            }]
        }
    	        , {
            items: [{
                name: 'name',
                fieldLabel: '键',
                width: 200,
                                allowBlank: true,
                value: cfg.row.get('name')
            }]
        }
    	        , {
            items: [{
                name: 'description',
                fieldLabel: '描述',
                width: 200,
                                allowBlank: true,
                value: cfg.row.get('description')
            }]
        }
    	        , {
            items: [{
                name: 'params',
                fieldLabel: '参数',
                width: 200,
                                allowBlank: true,
                value: cfg.row.get('params')
            }]
        }
    	    	    	    	]
    }, cfg));
};
Ext.extend(XsysDictionaryUpdateForm, Wo.FormPanel, {});